<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/12/15
 * Time: 22:19
 */

namespace App\Library\form_builder\src\traits;


trait TimePickerTrait
{
    /**
     * 时间选择组件
     *
     * @param            $field
     * @param            $title
     * @param string|int $value
     * @param string     $type
     * @return TimePicker
     */
    public static function timePicker($title,$field, $value = '', $type = TimePicker::TYPE_TIME)
    {
        return (new TimePicker($title,$field, $value))->type($type);
    }

    /**
     * 事件选择
     *
     * @param            $field
     * @param            $title
     * @param string|int $value
     * @return TimePicker
     */
    public static function time($title,$field, $value = '')
    {
        return self::timePicker($title,$field, (string)$value);
    }

    /**
     * 时间区间选择
     *
     * @param            $field
     * @param            $title
     * @param string|int $startTime
     * @param string|int $endTime
     * @return TimePicker
     */
    public static function timeRange($title,$field, $startTime = '', $endTime = '')
    {
        return self::timePicker($title,$field, [(string)$startTime, (string)$endTime], TimePicker::TYPE_TIME_RANGE);
    }
}